//
#ifndef INCLUDED_DATA_MAPPER_H
#define INCLUDED_DATA_MAPPER_H

#include <QObject>

/**
 * This is a class that performs point elimination on a given array of data.
 * The purpose of this is to compress out unwanted pixels and reduce draw time.
 * 
 * @author B. Lloyd
 * @since 2/2/2007
 */
class DataMapper
{    
public:
    DataMapper();
    DataMapper(double *pOrig, unsigned long origSize,unsigned long mapSize);
    ~DataMapper();

    void setOriginalData(double *pOrig, unsigned long size);
    void setMapSize(unsigned long size);
	bool setZoom(int lowerIndex, int upperIndex);
	void resetZoom();
	void zoomOut();
	bool getZoom(int& maxRange, int& lowerIndex, int& upperIndex);

    double rawAt(int pos);
    double pixelAt(int pos, bool *valid);
    int rawToPixel(int rawPos);
	int pixelPrevTo(int pos);
	int pixelNearestTo(int pos);
	int pixelToRaw(int pixel);
	long getDataSize();
    long getDataMapSize();
    //updateMap - called on resizing of plot
    void updateMap();

    int *pDataMap;

private:
    void expandDataMap(unsigned long size);

    //Pointer to originalData Buffer
    double *pOriginalData;
    int originalDataSize;

    //Pointer for the mapping array
    //Size of the data (basically #of pixels)
    long mappedDataSize;
    //size of the map array (for bookkeeping)
    unsigned long actualDataMapSize;
    bool    updateMapping;

	/* These control the "zoom" level */
	int zoomLower;
	int zoomUpper;
};

#endif
